<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>地址分布</title>
    <style type="text/css">
        html {
            height: 100%
        }

        body {
            height: 100%;
            margin: 0px;
            padding: 0px
        }

        #container {
            height: 100%
        }
    </style>
    <script type="text/javascript"
            src="https://api.map.baidu.com/api?v=1.0&type=webgl&ak=KCTqNj7rQ430oV9SMHGSMSgLHuEvdnZq">
    </script>
</head>

<body>
<div id="container"></div>
<!-- 引入样式 -->
<link rel="stylesheet" href="../plugins/elementui/index.css">
<link rel="stylesheet" href="../plugins/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="../css/style.css">
<!-- 引入组件库 -->
<script src="../js/vue.js"></script>
<script src="../plugins/elementui/index.js"></script>
<script src="../js/axios-0.18.0.js"></script>
<script>
    new Vue({
        data: {
            mapList: [],//存储地图上面的所以的点
        },
        created() {
            let map = new BMapGL.Map("container");// 创建地图实例
            map.setDefaultCursor("url('bird.cur')");   //设置地图默认的鼠标指针样式
            map.enableScrollWheelZoom();   //启用滚轮放大缩小，默认禁用
            map.enableContinuousZoom();    //启用地图惯性拖拽，默认禁用
            map.centerAndZoom(new BMapGL.Point(104.07, 30.67), 13);// 初始化地图，设置中心点坐标和地图级别


            axios.get("/map/findMap.do").then((response) => {
                if (response.data.flag) {
                    this.mapList = response.data.data;
                    //循环创建点
                    for (let i = 0; i < this.mapList.length; i++) {
                        let point = new BMapGL.Point(this.mapList[i].longitude, this.mapList[i].latitude);//京城国际地址
                        let marker = new BMapGL.Marker(point);        // 创建标注
                        map.addOverlay(marker);                     // 将标注添加到地图中
                        let label = new BMapGL.Label(this.mapList[i].address, {       // 创建文本标注
                            position: point,                          // 设置标注的地理位置
                            offset: new BMapGL.Size(10, -15)           // 设置标注的偏移量
                        });
                        map.addOverlay(label);
                    }


                }


            });
        },
    });


</script>

</body>
</html>





